/**
 * 路由总管理文件
 */

const fs = require('fs');
const path = require('path');
const Router = require('koa-router');
const router = new Router();

const files = fs.readdirSync(__dirname);    //获取当前路由文件夹下所有的文件
for (const file of files) {
    if (file === 'index.js' || file === 'common.js') continue;  //排除掉主路由文件
    const item = require(path.join(__dirname, file));   //导入子路由文件
    router.use(item.routes(), item.allowedMethods());   //注册子路由
}

module.exports = router;